home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Information / CSMP Digest / volume 1 / csmp-v1-144.txt < prev    next >
Text File  |  1992-12-31  |  45KB  |  1,249 lines

  1. C.S.M.P. Digest             Sun, 19 Jul 92       Volume 1 : Issue 144
  2.  
  3. Today's Topics:
  4.  
  5.     Changing Parameter Ram. Help!
  6.     How to use icon suites in menu items?
  7.     The need for speed: data and instruction caches. (SUMMARY)
  8.     Reading File Problems....
  9.     Pascal string to null terminated-How?
  10.     Changing a folder view
  11.     Dave Mark : Macintosh C Programming
  12.     Think C menu question
  13.  
  14.  
  15.  
  16. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  17.  
  18. The digest is a collection of article threads from the internet newsgroup
  19. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  20. regularly and want an archive of the discussions.  If you don't know what a
  21. newsgroup is, you probably don't have access to it.  Ask your systems
  22. administrator(s) for details.  (This means you can't post questions to the
  23. digest.)
  24.  
  25. Each issue of the digest contains one or more sets of articles (called
  26. threads), with each set corresponding to a 'discussion' of a particular
  27. subject.  The articles are not edited; all articles included in this digest
  28. are in their original posted form (as received by our news server at
  29. cs.uoregon.edu).  Article threads are not added to the digest until the last
  30. article added to the thread is at least one month old (this is to ensure that
  31. the thread is dead before adding it to the digest).  Article threads that
  32. consist of only one message are generally not included in the digest.
  33.  
  34. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  35. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  36. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  37. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  38. has a mail server; send a message with the text '$MACarch help' (no quotes)
  39. to LISTSERV@ricevm1.rice.edu for more information.
  40.  
  41. The digest is also available via email.  Just send a note saying that you
  42. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  43. automatically receive each new issue as it is created.  Sorry, back issues
  44. are not available through the mailing list.
  45.  
  46. Send administrative mail to mkelly@cs.uoregon.edu.
  47.  
  48.  
  49. -------------------------------------------------------
  50.  
  51. Subject: Changing Parameter Ram. Help!
  52. From: millem3@cosc.canterbury.ac.nz (Martin J. Miller)
  53. Date: 2 Jun 92 15:33:49 +1200
  54. Organization: Computer Science,University of Canterbury,New Zealand
  55.  
  56.    I am writing an INIT/cdev combination to alter the parameter ram (namely:
  57. mouse click, keyboard repeat/delay, sound volume, carat blink, menu blink).
  58.    I can change the pRAM but the system fails to notice until restart.
  59. (The changes are visible in Apple written cdevs, but the system does not
  60. utilize the new settings until restart [ie their is an inconsistency
  61. between the pram and what the system uses])
  62.    What must you do other than the following to make the changes visible?
  63. pSysParms := GetSysPPtr ;
  64.  { do some change on pSysParms^ }
  65. iErr := WriteParam ;
  66. { This is happily returning 0 and the status in pSysParms is good }
  67.    Also what does readxpram and writexpram do? And what are their
  68. parameters (if any)?
  69.   
  70. Any help would be most appreciated.
  71.    Thanks Martin Miller.
  72. ps Unfortuantely I can't reply to any emails as I am only an undergraduate
  73. student and was only granted this posting as an exception nor can I remote
  74. ftp!
  75.  
  76. +++++++++++++++++++++++++++
  77.  
  78. From: Andreas Wuertz <wuertz@systech.tik.ethz.ch>
  79. Organization: ETH TIK
  80. Date: Tue, 16 Jun 1992 15:31:39 GMT
  81.  
  82. >pSysParms := GetSysPPtr ;
  83.  
  84. Andy from TIK
  85.  
  86. =======================================================
  87. The earliest time for a program to be bug-free is,
  88. when it's out of date. The latest time for a programmer
  89. to retire is, when he writes such a program.
  90. =======================================================
  91.  
  92. +++++++++++++++++++++++++++
  93.  
  94. From: Andreas Wuertz <wuertz@systech.tik.ethz.ch>
  95. Organization: ETH TIK
  96. Date: Tue, 16 Jun 1992 15:33:08 GMT
  97.  
  98. Maybe you also need to update the low memory globals.
  99. See interface file 'SysEqu.p' for exact vars to change. 
  100. The rule is: if it's mentioned in Inside Mac, you may use
  101. it. Mostly you find mentions of the vars in the assembly
  102. language notes or in chapter summaries.
  103.  
  104. Example:
  105. File 'SysEqu.p':
  106. SPVolCtl = $208; {Speaker volume setting in parameter RAM (byte)}
  107. SdVolume = $260; {Current speaker volume (byte:  low-order three bits
  108. only)
  109. ^^^^SEE, there are TWO vars... find out yourself (using IM) which one to
  110. use (or even both).
  111.  
  112. Your Code:
  113. PROGRAM SetVolToOne;
  114. USES Types, SysEqu;
  115. VAR theVolume: Ptr; { which is ^SignedByte }
  116. BEGIN
  117.     theVolume:=Ptr(SPVolCtl);
  118.     theVolume^:=1; { sets the volume to 1 }
  119. END.
  120.  
  121. Hope this helps.
  122.  
  123. ---------------------------
  124.  
  125. From: heksterb@cs.utwente.nl (Ben Hekster)
  126. Subject: How to use icon suites in menu items?
  127. Date: 2 Jun 92 03:47:45 GMT
  128. Organization: University of Twente, Dept. of Computer Science
  129.  
  130. Does anyone know how to get icon suites in menu items?  Like the
  131. Apple and process menus do.
  132.  
  133.     From stepping through the menu bar definition function I've
  134. found that you can get an icon suite as a menu *title* by setting
  135. the title to a five-character string, with the first character as a
  136. '0x01' and the remaining four characters as the icon handle.  However,
  137. I haven't found how to get SuiteIcons into menu *items*.  I've tried
  138. doing the same but it doesn't work.
  139.  
  140.     It looks as if the handling of both the Apple and process
  141. menus is special-cased inside the 'MBDF'.  In both cases it calls
  142. _OSDispatch to get the icon handles to display.  Does this mean there
  143. is no interface for this yet?
  144.  
  145.     Has anyone looked into this?  I think I checked all the
  146. relevant Technical Notes (including the recently updated TN 306) but
  147. I can't find any mention of it.
  148.  
  149. - -- 
  150. Ben `Hackster' Hekster        | "Die Qualita:t des Lebens
  151. heksterb@cs.utwente.nl        |  Aus kleinem, intelligentem Element"
  152.  
  153. +++++++++++++++++++++++++++
  154.  
  155. From: Andreas Wuertz <wuertz@systech.tik.ethz.ch>
  156. Organization: ETH TIK
  157. Date: Tue, 16 Jun 1992 15:47:13 GMT
  158.  
  159. >I can't find any mention of it.
  160.  
  161. You can't find any mention, but you can simply DO
  162. it using ResEdit 2.1.1: Create a menu, create an
  163. item for that menu and choose 'Set Icon' from the
  164. 'Menu'-menu. Say 'Small Icon Resource' and 'New'
  165. in the upcoming dialog and see (opening the menu
  166. with the MENU-Template, not the MENU-Editor) how
  167. ResEdit has done magic and provided an Icon ID of
  168. 94 (or so) and created an SICN of ID 352. But it
  169. works! I'm sure one could find out the relation
  170. between the two numbers, but why if resedit does
  171. it? No the next clue: add a 'cicn' with same id
  172. as the SICN (352, not 94) and you get a menu item
  173. with a colour small icon!
  174.  
  175. Hope this works on YOUR mac, too... :-)
  176.  
  177. Andy from TIK
  178.  
  179. =======================================================
  180. The earliest time for a program to be bug-free is,
  181. when it's out of date. The latest time for a programmer
  182. to retire is, when he writes such a program.
  183. =======================================================
  184.  
  185. ---------------------------
  186.  
  187. From: jesjones@milton.u.washington.edu (Jesse Jones)
  188. Subject: The need for speed: data and instruction caches. (SUMMARY)
  189. Date: 10 Jun 92 16:17:37 GMT
  190. Organization: University of Washington, Seattle
  191.  
  192.  
  193.              The need for speed: data and instruction caches.
  194.              
  195.    I posted an article a while back asking about how the data caches on the
  196. Quadra worked. I'm the author of a fractal program that ran at about the
  197. same speed on a Quadra and an SE/30. It turns out that the algorithm I
  198. used was just about the worst possible for the '040.
  199.  
  200.    I received several replies to my original article. William Graham was 
  201. kind enough to send me some excerpts from a two part article on the '040 in 
  202. the February 1990 and June 1990 IEEE Micro. Harry Eaton mailed me a copy of
  203. TN 261 Cache as Cache can (I got a corrupted file when I tried to FTP it).
  204.  
  205.    I'm posting this summary because several of the people who replied to
  206. my article seemed confused about how the '040s caches worked. Tech Note 261
  207. is well written but doesn't discuss how the caches actually work. (It's 
  208. basicly a primer on how to write your programs so that they are  compatible
  209. with the caches).
  210.  
  211. Here's how the caches are organized on the various processors:
  212.  
  213. Processor      Instruction      Data                
  214. 68020          64 long-words    none        
  215.  
  216. 68030          64 long-words    64 long-words (write-through)
  217.  
  218. 68040          256 lines        256 lines (each line is 16 bytes)
  219.  
  220.    The caches on the '020 and '030 are 256 bytes. The caches on the '040
  221. are a whopping 4096 bytes. The caches work on blocks of memory. For the
  222. '020 and '030 each cache entry is a long-word. For the '040 a cache entry
  223. is 16 bytes. So, for example, on a '040 if a word at some address A is
  224. cached the following 14 bytes will be cached as well.
  225.  
  226.    The cache modes control how cache entries are allocated and when data is
  227. written to memory. They work as follows:
  228.  
  229. Copy-Back mode keeps data in the cache without writing it to memory. Data is
  230. written to memory only when a cache entry is de-allocated. Cache entries are
  231. allocated whenever a WRITE fails.
  232.  
  233. Write-Through writes changes to both the cache and memory. Cache entries are
  234. allocated on READs.
  235.  
  236.    A large part of the performance of the Quadras is due to the instruction
  237. and data caches. If the caches are not used effectively performance will
  238. take a nose dive. It's important to keep your memory accesses as clustered
  239. as possible so that as much of the cache entry is used as possible (this is
  240. where I went wrong). The cache mode is also important. It should be changed
  241. depending on if you are reading or writing to the same locations frequently.
  242.  
  243.    --Jesse
  244.  
  245. +++++++++++++++++++++++++++
  246.  
  247. From: sje@xylos.ma30.bull.com (Steven J. Edwards)
  248. Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA
  249. Date: 10 Jun 92 14:20:47
  250.  
  251. In article <1992Jun10.161737.23563@u.washington.edu> jesjones@milton.u.washington.edu (Jesse Jones) writes:
  252. >   Here's how the caches are organized on the various processors:
  253. >
  254. > Processor      Instruction      Data                
  255. > 68020          64 long-words    none        
  256. >
  257. > 68030          64 long-words    64 long-words (write-through)
  258. >
  259. > 68040          256 lines        256 lines (each line is 16 bytes)
  260. >
  261. >    The caches on the '020 and '030 are 256 bytes. The caches on the '040
  262. > are a whopping 4096 bytes. The caches work on blocks of memory. For the
  263. > '020 and '030 each cache entry is a long-word. For the '040 a cache entry
  264. > is 16 bytes. So, for example, on a '040 if a word at some address A is
  265. > cached the following 14 bytes will be cached as well.
  266.  
  267. Actually, it's not necessarially "the following 14 bytes" that are
  268. cached in the '040.  Rather, each line of cache in use at a particular
  269. time is associated with a sixteen byte long chunk of memory starting
  270. at an address that is 16 byte aligned.  Similarly, the '030 and '020
  271. lines cache four byte chunks that correspond to 4 byte aligned memory
  272. addresses.
  273.  
  274. And to no one in particular:
  275.  
  276. Commandment 0x1b2f says:
  277.  
  278. Thou shall not write self modifying code for it displeaseth thy fellow
  279. programmers to hear the same sad song when thou doest complaineth
  280. afterwards showing thy ignorance of cache mechanics.
  281.  
  282.  [The above opinions expressed are my own; not necessarily held by others.]
  283.       == Steven J. Edwards           Bull HN Information Systems Inc. ==
  284.       == (508) 294-3484              300 Concord Road         MS 820A ==
  285.       == sje@xylos.ma30.bull.com     Billerica, MA 01821          USA ==
  286. "That Government which Governs the Least, Governs Best." -- Thomas Jefferson
  287.  
  288. +++++++++++++++++++++++++++
  289.  
  290. From: bayes@hplvec.LVLD.HP.COM (Scott Bayes)
  291. Date: Mon, 15 Jun 1992 22:15:38 GMT
  292. Organization: Hewlett-Packard Co., Loveland, CO
  293.  
  294. > Copy-Back mode keeps data in the cache without writing it to memory. Data is
  295. > written to memory only when a cache entry is de-allocated. Cache entries are
  296. > allocated whenever a WRITE fails.
  297.  
  298. Note that the amount of data written to RAM when the entry is flushed
  299. may vary. 
  300.  
  301. The cacheline is laid out so (logically)
  302.  
  303. L1 L2 L3 L4 D1 D2 D3 D4
  304.  
  305. Where Li are longwords, and Di are dirty bits associated with them.
  306.  
  307. If exactly one longword in the cacheline is marked "dirty" (any byte or
  308. word or the whole longword has been modified by the CPU), only it is
  309. flushed.  If more than one has been so marked, the whole cacheline is
  310. written back to RAM.
  311.  
  312. This can lead to interesting interactions with DMA, if "bus-snooping" is
  313. not enabled.
  314.  
  315. Say a DMA buffer is in RAM aligned so that it doesn't cover completely
  316. the cache line at one end or the other of the cacheline.  In that part
  317. of the cacheline, you put a variable.
  318.  
  319. Now, you start an inbound DMA transfer to the buffer.  All the data
  320. arrives, but, because bus-snooping is turned off, the CPU doesn't know
  321. that the data in the buffer is new.  Meanwhile, the value of the
  322. variable is changed, dirtying the cacheline to some extent.  If that
  323. line happens to be flushed before the data in the buffer part of it is
  324. used, the old, "stale" contents of the line get flushed back over the
  325. buffer, corrupting it.
  326.  
  327. This actually happened on our non-Mac 68040 CPU, where bus-snooping does
  328. not work correctly, so is disabled.  It was _very_ tough to find.
  329.  
  330. Scott Bayes
  331.  
  332. ---------------------------
  333.  
  334. From: jedwards@gmuvax2.gmu.edu (James Edwards)
  335. Subject: Reading File Problems....
  336. Organization: George Mason University, Fairfax, Va.
  337. Date: Wed, 10 Jun 1992 19:33:22 GMT
  338.  
  339. I have a problem doing some file manipulation, and was wondering if
  340. anyone could help out.  I am writing a program in Think C 5.0, that
  341. basically reads in a text file, which can sometimes be over 200K, pull
  342. some data out, and write that data to another text file.  This should be
  343. very straight forward.  I am not using the ANSI routines because I need
  344. this to be Mac friendly, so am using SFGetFile and FSCreate, FSOpen, and
  345. all those other high-level file routines.  My problem is this:
  346.  
  347. When I read in the file, I get an error from the SetFPos routine when I
  348. try and set it beyond 32K.  I know the variables are all type long, so I
  349. can't be overloading an integer, I'm not using TextEdit in any way, so I
  350. shouldn't be running into any limitations there, I just can't figure it
  351. out.  I know that Think C has a 32K limitation on the size of an array,
  352. so I am only reading in 10000 bytes at a time, processing them, writing
  353. them out, and then moving the pointer and reading the next 10000.  I have
  354. scanned the Inside Macs as best I could, and couldn't find any reference
  355. to why this wouldn't work.  If someone out there could please let me know
  356. if this is a built in limitation, or how to get around it.  It really
  357. makes me sick, I could have had this done days ago writing it in
  358. something like QBasic....
  359.  
  360. Jimi
  361.  
  362. jedwards@gmuvax2.gmu.edu
  363.  
  364.  
  365. +++++++++++++++++++++++++++
  366.  
  367. From: oster@well.sf.ca.us (David Phillip Oster)
  368. Organization: Whole Earth 'Lectronic Link
  369. Date: Sat, 13 Jun 1992 04:53:02 GMT
  370.  
  371. In article <1992Jun10.193322.19587@gmuvax2.gmu.edu> jedwards@gmuvax2.gmu.edu (James Edwards) writes:
  372. >out.  I know that Think C has a 32K limitation on the size of an array,
  373. Not so! In the current version, check the "far data" option tto allow larger
  374. gloabl arrays. Local arrays are limited by the size of the stack, and by the
  375. instructions generated to create a stack frame, but for please use NewPtr().
  376. That is what it is there for. If you have the heapo space, there is no
  377. problem with:
  378. GetEOF(ref, &len);
  379. buf = NewPtr(len);
  380. FSRead(ref, &len, buf);
  381.  
  382. (Always check for errors in a real program.)
  383. and SetFPos(ref, fsFromStart, where    works fine too.
  384. Make sure that "where" is declared long, and that it is initialized via
  385. a properly cast expression. Right:
  386. long where = 500L * sizeof(MyStruct);
  387. Wrong:
  388. long where = (long) shortVar * shortVar;
  389.  
  390. (I use ((long) shortVar) * shortVar) for safety.)  Use the source level
  391. debugger (in think C) it will tell you whether someting is screwing up
  392. the sign extension of your intermediate calculations.
  393.  
  394. +++++++++++++++++++++++++++
  395.  
  396. From: mkahl@world.std.com (Michael Kahl)
  397. Organization: Enginuity Inc.
  398. Date: Tue, 16 Jun 1992 13:43:04 GMT
  399.  
  400. In article <1992Jun13.045302.10747@well.sf.ca.us> oster@well.sf.ca.us (David Phillip Oster) writes:
  401. >Local arrays are limited by the size of the stack, and by the
  402. >instructions generated to create a stack frame, ...
  403.  
  404. THINK C 5 knows how to generate code for large stack frames, although it is
  405. still up to you to assure sufficient stack space by calling SetApplLimit.
  406.  
  407. >Make sure that "where" is declared long, and that it is initialized via
  408. >a properly cast expression. Right:
  409. >long where = 500L * sizeof(MyStruct);
  410. >Wrong:
  411. >long where = (long) shortVar * shortVar;
  412.  
  413. This is not wrong.  Casts bind tighter than multiplication.
  414.  
  415. - -- 
  416. Michael Kahl      mkahl@world.std.com
  417. Disclaimer:  Whoa!  Did I say THAT??!
  418.  
  419. ---------------------------
  420.  
  421. Subject: Pascal string to null terminated-How?
  422. From: skinner@oread.cc.ukans.edu
  423. Date: 15 Jun 92 06:51:19 CST
  424. Organization: University of Kansas Academic Computing Serces
  425.  
  426. This is a quick one but I am at a loss.  How do I convert a pascal
  427. string to a null terminated string.  What I need is something like
  428. Hypercard's PasToZero function. I have an example in C but I
  429. am using Pascal.  Thanks.
  430.  
  431. skinner@next1.cs.ukans.edu
  432. or
  433. skinner@oread.cc.ukans.edu
  434.  
  435. +++++++++++++++++++++++++++
  436.  
  437. From: keith@taligent.com (Keith Rollin)
  438. Date: 15 Jun 92 20:31:15 GMT
  439. Organization: Taligent
  440.  
  441. In article <1992Jun15.065119.1@oread.cc.ukans.edu>, skinner@oread.cc.ukans.edu
  442. writes:
  443. > This is a quick one but I am at a loss.  How do I convert a pascal
  444. > string to a null terminated string.  What I need is something like
  445. > Hypercard's PasToZero function. I have an example in C but I
  446. > am using Pascal.  Thanks.
  447.  
  448. With MPW, in Strings.p, there is a function call P2CStr that converts a string
  449. "in place" (meaning that the memory holding the pascal string ends up holding a
  450. c-string).
  451.  
  452. I don't know if THINK Pascal has the same function.
  453.  
  454. - --
  455. Keith Rollin
  456. Phantom Programmer
  457. Taligent, Inc.
  458.  
  459.  
  460. +++++++++++++++++++++++++++
  461.  
  462. From: eric@homebase.vistachrome.com (Eric Brunson)
  463. Organization: Vista-Chrome Incorporated
  464. Date: Tue, 16 Jun 1992 13:02:31 GMT
  465.  
  466. keith@taligent.com (Keith Rollin) writes:
  467.  
  468. >In article <1992Jun15.065119.1@oread.cc.ukans.edu>, skinner@oread.cc.ukans.edu
  469. >writes:
  470. >> 
  471. >> This is a quick one but I am at a loss.  How do I convert a pascal
  472. >> string to a null terminated string.  What I need is something like
  473. >> Hypercard's PasToZero function. I have an example in C but I
  474. >> am using Pascal.  Thanks.
  475.  
  476. >With MPW, in Strings.p, there is a function call P2CStr that converts a string
  477. >"in place" (meaning that the memory holding the pascal string ends up holding a
  478. >c-string).
  479.  
  480. >I don't know if THINK Pascal has the same function.
  481.  
  482. Rather than convert back and forth between C and Pascal strings, I have
  483. a simple function to null terminate the P string:
  484.  
  485. void termPstr( char *string )
  486. {
  487.     string[ string[0] + 1 ] = 0;
  488. }
  489.  
  490. Then, if I ever need to pass a pointer to a C string I pass string+1,
  491. and use string normally as a Pascal string.  ( Checking the bounds of
  492. the memory allocated to the original string is left as an exercise. )
  493.  
  494. If you wanted to write your own PtoCStr this works:
  495.  
  496. void PtoCstr( char *string )
  497. {
  498.     BlockMove( string + 1, string, string[0] );
  499. }
  500.  
  501. Something similar could be used for CtoPstr using strlen for the length
  502. og the C string.
  503.  
  504. Hope this helps...
  505.  
  506. - -- 
  507. Eric Brunson               These opinions are mine alone,
  508. eric@vistachrome.com         but they could be yours for a low monthly fee!
  509. "He's a genius, eh, he hooked up our stereo."
  510.  
  511. +++++++++++++++++++++++++++
  512.  
  513. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  514. Organization: Kalamazoo College
  515. Date: Tue, 16 Jun 1992 14:11:31 GMT
  516.  
  517. eric@homebase.vistachrome.com (Eric Brunson) writes:
  518. >
  519. >If you wanted to write your own PtoCStr this works:
  520. >
  521. >void PtoCstr( char *string )
  522. >{
  523. >    BlockMove( string + 1, string, string[0] );
  524. >}
  525.  
  526. Nope.  It doesn't guarantee zero-termination, and bombs with strings
  527. longer than 127 chars.  Try
  528.  
  529. void newAndImprovedPToCStr(register unsigned char *string)
  530. {
  531.     register short length = string[0];
  532.     BlockMove( string+1, string, length );
  533.     string[length] = '\0';
  534. }
  535. - -- 
  536.  Jamie McCarthy     Internet: k044477@kzoo.edu     AppleLink: j.mccarthy
  537.  Never make MENU resources purgeable.
  538.  
  539. ---------------------------
  540.  
  541. From: macman@edwards.WPI.EDU (Chris Silverberg)
  542. Subject: Changing a folder view
  543. Organization: Worcester Polytechnic Institute
  544. Date: Tue, 16 Jun 1992 02:42:06 GMT
  545.  
  546. I have a program that creates some folders and I would *like* to set the view
  547. within the program (by name, icon, etc.)  But how to accomplish this doesn't
  548. seem to be documented anywhere, unless it's hidden in a technote somewhere.
  549. Does anyone have the insides scoop?
  550.  
  551. THINK Reference says of the DInfo structure: "The content of the frView field
  552. is not documented, the high byte of this field is one of: 1 By Icon,
  553. 2 By Name, 3 By Date, 4 By Size, 5 By Kind, 6 By Color."
  554.  
  555. So here is my code to attempt to change a directory to By Name.  Note
  556. that the PBSetCatInfo and PBGetCatInfo return 'noErr', but the also dont seem
  557. to work.
  558.  
  559.  
  560.  
  561. void MakeDir( Str255 mailPath )
  562. {
  563.    int            err;
  564.    CInfoPBRec    cipb;
  565.    DirInfo        *theDir = (DirInfo *) &cipb;
  566.     
  567.    DirCreate( 0, 0L, mailPath, NIL_POINTER );  /* <-- this works fine */
  568.    theDir->ioNamePtr = mailPath;
  569.    theDir->ioVRefNum = 0;
  570.    theDir->ioDrDirID = 0L;
  571.    theDir->ioFDirIndex = 0;
  572.    err = PBGetCatInfo( &cipb, FALSE );         /* no error */
  573.    if ( err != noErr )
  574.       /* process error */
  575.    theDir->ioDrDirID = 0L;
  576.  
  577.    (theDir->ioDrUsrWds).frView = (2*256)+((theDir->ioDrUsrWds).frView % 256 );
  578.    err = PBSetCatInfo( &cipb, FALSE );          /* no error, but no   */
  579.    if ( err != noErr )                          /* change either      */
  580.       /* process error */
  581. }
  582.  
  583.  
  584.  =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  585.    Chris Silverberg                     INTERNET: macman@wpi.wpi.edu
  586.    Worcester Polytechnic Institute      WMUG BBS  508-832-5844 (TeleFinder)
  587.    America Online: TfChris              FIDONET:  1:322/115.1
  588.  
  589. +++++++++++++++++++++++++++
  590.  
  591. From: keith@taligent.com (Keith Rollin)
  592. Date: 16 Jun 92 17:26:40 GMT
  593. Organization: Taligent
  594.  
  595. In article <1992Jun16.024206.428@wpi.WPI.EDU>, macman@edwards.WPI.EDU (Chris
  596. Silverberg) writes:
  597. > I have a program that creates some folders and I would *like* to set the view
  598. > within the program (by name, icon, etc.)  But how to accomplish this doesn't
  599. > seem to be documented anywhere, unless it's hidden in a technote somewhere.
  600. > Does anyone have the insides scoop?
  601. > THINK Reference says of the DInfo structure: "The content of the frView field
  602. > is not documented, the high byte of this field is one of: 1 By Icon,
  603. > 2 By Name, 3 By Date, 4 By Size, 5 By Kind, 6 By Color."
  604. > So here is my code to attempt to change a directory to By Name.  Note
  605. > that the PBSetCatInfo and PBGetCatInfo return 'noErr', but the also dont seem
  606. > to work.
  607. > void MakeDir( Str255 mailPath )
  608. > {
  609. >    int            err;
  610. >    CInfoPBRec    cipb;
  611. >    DirInfo        *theDir = (DirInfo *) &cipb;
  612. >     
  613. >    DirCreate( 0, 0L, mailPath, NIL_POINTER );  /* <-- this works fine */
  614. >    theDir->ioNamePtr = mailPath;
  615. >    theDir->ioVRefNum = 0;
  616. >    theDir->ioDrDirID = 0L;
  617. >    theDir->ioFDirIndex = 0;
  618. >    err = PBGetCatInfo( &cipb, FALSE );         /* no error */
  619. >    if ( err != noErr )
  620. >       /* process error */
  621. >    theDir->ioDrDirID = 0L;
  622. >    (theDir->ioDrUsrWds).frView = (2*256)+((theDir->ioDrUsrWds).frView % 256 );
  623. >    err = PBSetCatInfo( &cipb, FALSE );          /* no error, but no   */
  624. >    if ( err != noErr )                          /* change either      */
  625. >       /* process error */
  626. > }
  627.  
  628. You'll probably have to set the "inited" bit in the Finder flags, or else the
  629. Finder will imprint its own idea of what the folder should look like the first
  630. time you open it up.
  631.  
  632. By the way, I think the following information is accurate for 7.0:
  633.  
  634.                 Upper byte                    Lower byte
  635.                 ----------                    ---------
  636.  
  637.                 1 = spatial view        bit 0 = 
  638.                        (by icon or         bit 1 = 
  639.                        small icon)            bit 2 = 
  640.                 2 = by name                   bit 3 = 
  641.                 3 = by date                   bit 4 = 
  642.                 4 = by size                   bit 5 = 1 means window is zoomed
  643.                 5 = by kind                   bit 6 = 1 means spatial view
  644.                 6 = by comments                          is by small icon
  645.                 7 = by label               bit 7 = 
  646.                 8 = by version
  647.  
  648. The upper byte of frView is zero for some folders (like the Desktop folder). I'm
  649. not sure what that means.
  650.  
  651. - --
  652. Keith Rollin
  653. Phantom Programmer
  654. Taligent, Inc.
  655.  
  656.  
  657. ---------------------------
  658.  
  659. From: mattes@comp.bioz.unibas.ch (Frank Mattes)
  660. Subject: Dave Mark : Macintosh C Programming
  661. Date: 16 Jun 92 12:35:12 GMT
  662. Organization: EMBnet Switzerland [Basel]
  663.  
  664. In this group I have read about the book from Dave Mark, Macintosh C ProgrammingPrimer, Volume I. Does anybody knows which is the newest editon of this book.
  665.  
  666. Thanks for your help
  667.  
  668. Frank
  669.  
  670. +++++++++++++++++++++++++++
  671.  
  672. From: davison@living.rutgers.edu (Brian D. Davison)
  673. Date: 16 Jun 92 14:06:42 GMT
  674. Organization: Rutgers Univ., New Brunswick, N.J.
  675.  
  676. In article <mattes.708698112@biox>, mattes@comp.bioz.unibas.ch (Frank Mattes) writes:
  677. > In this group I have read about the book from Dave Mark, Macintosh C
  678. > ProgrammingPrimer, Volume I. Does anybody knows which is the newest
  679. > editon of this book.
  680. > Thanks for your help
  681. > Frank
  682.  
  683. _Macintosh_C_Programming_Primer_, Vol. 1, is now in its second edition.
  684. $26.95 (US), published by Addison Wesley (1992), written by Dave Mark
  685. and Cartwright Reed.  ISBN#0-201-60838-3.
  686.  
  687. A little more technical, but also new, is the second edition of 
  688. _Macintosh_Programming_Secrets_, by Scott Knaster and Keith Rollin,
  689. also published by Addison Wesley (1992), at $29.95 (US).
  690. ISBN# 0-201-58134-5.
  691.  
  692.  
  693. [I have no relation to either of these books, except as a satisfied
  694. customer.  :-)]
  695. - -- 
  696. Brian D. Davison                    Department of Computer Science
  697.                                     Rutgers, The State University of New Jersey
  698. davison@paul.rutgers.edu            Hill Center, 3rd floor, Busch Campus
  699. !rutgers!paul.rutgers.edu!davison   Piscataway, NJ  08855-1179
  700.  
  701. +++++++++++++++++++++++++++
  702.  
  703. From: marshall@kauri.vuw.ac.nz (Stephen Marshall)
  704. Date: Tue, 16 Jun 1992 22:37:21 GMT
  705. Organization: Victoria University of Wellington, New Zealand
  706.  
  707. Speaking of the C primer, does anyone know if the Pascal primer vol2 has
  708. been written? Or is Dave too busy writting the 2nd edition of the C primer
  709. to complete the pascal?
  710.  
  711. Stephen
  712.  
  713. ---------------------------
  714.  
  715. From: djpegg@utkvx2.utk.edu (PEGG, DAVID J)
  716. Subject: Think C menu question
  717. Organization: University of Tennessee Computing Center
  718. Date: Wed, 10 Jun 1992 15:58:00 GMT
  719.  
  720. Hi,
  721.  
  722. I'm a bit of a novice so I was hoping someone could help me with
  723. a problem.  I'm using Think C 5.0.2 and am having trouble getting
  724. menus to show up on bar.  They work fine, but only one is visible.
  725. I decided to copy a program out of a book ("Using the Macintosh
  726. Toolbox with C" by Huxam et.al.) but still no luck.  I cut it down
  727. to what I thought were the bare essentials to put two menus in the
  728. menu bar.   Still only one appeared. Could someone tell me what I'm
  729. doing wrong?
  730.  
  731. /*********************************/
  732. MenuHandle            MyMenu,OurMenu;
  733.  
  734. SetUpMenus()
  735. {
  736.     OurMenu = NewMenu(102,"\pOurMenu");
  737.     AppendMenu(OurMenu,"\pHide;Show/S");
  738.     InsertMenu(OurMenu,0);
  739.     
  740.     MyMenu = NewMenu(103,"\pMyMenu");
  741.     AppendMenu(MyMenu,"\pFirst;Second/M");
  742.     InsertMenu(MyMenu,0);
  743.     
  744.     DrawMenuBar();
  745. }
  746.  
  747. main()
  748. {
  749.     InitGraf(&thePort);
  750.     InitFonts();
  751.     InitWindows();
  752.     InitCursor();
  753.     FlushEvents(everyEvent,0);
  754.     InitMenus();
  755.     SetUpMenus();
  756.     while(!Button())
  757.     {
  758.     }
  759. }
  760. /**************************/
  761.  
  762. Thanks for any help, Joe Dellwo.
  763.  
  764. +++++++++++++++++++++++++++
  765.  
  766. From: keith@taligent.com (Keith Rollin)
  767. Date: 10 Jun 92 21:29:16 GMT
  768. Organization: Taligent
  769.  
  770. In article <10JUN199210580875@utkvx2.utk.edu>, djpegg@utkvx2.utk.edu (PEGG,
  771. DAVID J) writes:
  772. > Hi,
  773. > I'm a bit of a novice so I was hoping someone could help me with
  774. > a problem.  I'm using Think C 5.0.2 and am having trouble getting
  775. > menus to show up on bar.  They work fine, but only one is visible.
  776. > I decided to copy a program out of a book ("Using the Macintosh
  777. > Toolbox with C" by Huxam et.al.) but still no luck.  I cut it down
  778. > to what I thought were the bare essentials to put two menus in the
  779. > menu bar.   Still only one appeared. Could someone tell me what I'm
  780. > doing wrong?
  781. > /*********************************/
  782. > MenuHandle            MyMenu,OurMenu;
  783. > SetUpMenus()
  784. > {
  785. >     OurMenu = NewMenu(102,"\pOurMenu");
  786. >     AppendMenu(OurMenu,"\pHide;Show/S");
  787. >     InsertMenu(OurMenu,0);
  788. >     
  789. >     MyMenu = NewMenu(103,"\pMyMenu");
  790. >     AppendMenu(MyMenu,"\pFirst;Second/M");
  791. >     InsertMenu(MyMenu,0);
  792. >     
  793. >     DrawMenuBar();
  794. > }
  795. > main()
  796. > {
  797. >     InitGraf(&thePort);
  798. >     InitFonts();
  799. >     InitWindows();
  800. >     InitCursor();
  801. >     FlushEvents(everyEvent,0);
  802. >     InitMenus();
  803. >     SetUpMenus();
  804. >     while(!Button())
  805. >     {
  806. >     }
  807. > }
  808. >
  809.  
  810. You're going to hate this, but "It works for me." I took your code, stuck into a
  811. source file, declared OurMenu and MyMenu, and compiled it under THINK C 5.0.2.
  812. Both menus showed up. I ran the program stand-alone and also under THINK C.
  813.  
  814. If I were in your position, I'd start taking a look at the stuff hanging off of
  815. the low-memory global MenuList. It's documented in the Menu Manager Chapter of
  816. IM V (actually, I think that the information in Inside Mac I is sufficient for
  817. you, and it's a lot clearer than IM V).
  818.  
  819. - --
  820. Keith Rollin
  821. Phantom Programmer
  822. Taligent, Inc.
  823.  
  824.  
  825. +++++++++++++++++++++++++++
  826.  
  827. From: markw@wc.novell.com (Mark Wittenberg)
  828. Organization: Novell, Inc.
  829. Date: 11 Jun 92 00:44:03 GMT
  830.  
  831. In <68510@apple.Apple.COM> keith@taligent.com (Keith Rollin) writes:
  832.  
  833. >In article <10JUN199210580875@utkvx2.utk.edu>, djpegg@utkvx2.utk.edu (PEGG,
  834. >DAVID J) writes:
  835. >> 
  836. >> Hi,
  837. >> 
  838. >> I'm a bit of a novice so I was hoping someone could help me with
  839. >> a problem.  I'm using Think C 5.0.2 and am having trouble getting
  840. >> menus to show up on bar.  They work fine, but only one is visible.
  841. >> I decided to copy a program out of a book ("Using the Macintosh
  842. >> Toolbox with C" by Huxam et.al.) but still no luck.  I cut it down
  843. >> to what I thought were the bare essentials to put two menus in the
  844. >> menu bar.   Still only one appeared. Could someone tell me what I'm
  845. >> doing wrong?
  846. >> 
  847. >> /*********************************/
  848. >> MenuHandle            MyMenu,OurMenu;
  849. >> 
  850. >> SetUpMenus()
  851. >> {
  852. >>     OurMenu = NewMenu(102,"\pOurMenu");
  853. >>     AppendMenu(OurMenu,"\pHide;Show/S");
  854. >>     InsertMenu(OurMenu,0);
  855. >>     
  856. >>     MyMenu = NewMenu(103,"\pMyMenu");
  857. >>     AppendMenu(MyMenu,"\pFirst;Second/M");
  858. >>     InsertMenu(MyMenu,0);
  859. >>     
  860. >>     DrawMenuBar();
  861. >> }
  862. >> 
  863. >> main()
  864. >> {
  865. >>     InitGraf(&thePort);
  866. >>     InitFonts();
  867. >>     InitWindows();
  868. >>     InitCursor();
  869. >>     FlushEvents(everyEvent,0);
  870. >>     InitMenus();
  871. >>     SetUpMenus();
  872. >>     while(!Button())
  873. >>     {
  874. >>     }
  875. >> }
  876. >>
  877.  
  878. >You're going to hate this, but "It works for me." I took your code, stuck into a
  879. >source file, declared OurMenu and MyMenu, and compiled it under THINK C 5.0.2.
  880. >Both menus showed up. I ran the program stand-alone and also under THINK C.
  881.  
  882. >If I were in your position, I'd start taking a look at the stuff hanging off of
  883. >the low-memory global MenuList. It's documented in the Menu Manager Chapter of
  884. >IM V (actually, I think that the information in Inside Mac I is sufficient for
  885. >you, and it's a lot clearer than IM V).
  886.  
  887. >--
  888. >Keith Rollin
  889. >Phantom Programmer
  890. >Taligent, Inc.
  891.  
  892. I'd check to make sure that the menu id field of the menu resources
  893. is in fact 102 and 103, respectively (no, not the resource id, but MenuID,
  894. the first field).  ResEdit doesn't automatically set the first field of
  895. a menu to be the same as its resource id, but if it's different the menu
  896. doesn't show up.  Anyone want to take bets that the MenuID fields
  897. are 128 and 129?  This should be in the FAQ if it's not.
  898.  
  899. /markw
  900. - --
  901. - ---
  902. Mark Wittenberg            Voice:        (510) 975-4512
  903. Novell, Inc.            Internet:    markw@wc.novell.com
  904. 1340 Treat Blvd. Suite 500    UUCP:        uunet!kinetics!markw
  905.  
  906. +++++++++++++++++++++++++++
  907.  
  908. From: bin@primate.wisc.edu (Brain in Neutral)
  909. Date: 11 Jun 92 16:14:38 GMT
  910.  
  911. >From article <markw.708223443@wc.novell.com>, by markw@wc.novell.com (Mark Wittenberg):
  912. > I'd check to make sure that the menu id field of the menu resources
  913. > is in fact 102 and 103, respectively (no, not the resource id, but MenuID,
  914. > the first field).  ResEdit doesn't automatically set the first field of
  915. > a menu to be the same as its resource id, but if it's different the menu
  916. > doesn't show up.  Anyone want to take bets that the MenuID fields
  917. > are 128 and 129?  This should be in the FAQ if it's not.
  918.  
  919. Your observations are correct when one is using menu *resources* (I got
  920. bit by this myself last weekend, grrr.)  However, the code in question
  921. uses NewMenu, not GetMenu, so this can't be the answer: no resources are
  922. involved.
  923.  
  924.     > SetUpMenus()
  925.     > {
  926.     >       OurMenu = NewMenu(102,"\pOurMenu");
  927.     >       AppendMenu(OurMenu,"\pHide;Show/S");
  928.     >       InsertMenu(OurMenu,0);
  929.     >
  930.     >       MyMenu = NewMenu(103,"\pMyMenu");
  931.     >       AppendMenu(MyMenu,"\pFirst;Second/M");
  932.     >       InsertMenu(MyMenu,0);
  933.     >
  934.     >       DrawMenuBar();
  935.  
  936. Paul DuBois
  937. dubois@primate.wisc.edu
  938.  
  939. +++++++++++++++++++++++++++
  940.  
  941. From: keith@taligent.com (Keith Rollin)
  942. Date: 11 Jun 92 18:42:54 GMT
  943. Organization: Taligent
  944.  
  945. In article <6240@uakari.primate.wisc.edu>, bin@primate.wisc.edu (Brain in
  946. Neutral) writes:
  947. > From article <markw.708223443@wc.novell.com>, by markw@wc.novell.com (Mark
  948. Wittenberg):
  949. > > I'd check to make sure that the menu id field of the menu resources
  950. > > is in fact 102 and 103, respectively (no, not the resource id, but MenuID,
  951. > > the first field).  ResEdit doesn't automatically set the first field of
  952. > > a menu to be the same as its resource id, but if it's different the menu
  953. > > doesn't show up.  Anyone want to take bets that the MenuID fields
  954. > > are 128 and 129?  This should be in the FAQ if it's not.
  955. > Your observations are correct when one is using menu *resources* (I got
  956. > bit by this myself last weekend, grrr.)  However, the code in question
  957. > uses NewMenu, not GetMenu, so this can't be the answer: no resources are
  958. > involved.
  959.  
  960. Please keep in mind that normally it is just fine for menu IDs to be different
  961. from resource IDs. The problem comes up when you use something that erroneously
  962. (or as a matter of convenience) assumes they are the same. This includes MacApp,
  963. TCL, and the System 7 Popupmenu CDEF. In plain old applications, you can make
  964. the resource ID different from the menu ID.
  965.  
  966. - --
  967. Keith Rollin
  968. Phantom Programmer
  969. Taligent, Inc.
  970.  
  971. +++++++++++++++++++++++++++
  972.  
  973. From: markw@wc.novell.com (Mark Wittenberg)
  974. Organization: Novell, Inc.
  975. Date: 11 Jun 92 19:59:32 GMT
  976.  
  977. In <68571@apple.Apple.COM> keith@taligent.com (Keith Rollin) writes:
  978.  
  979. >In article <6240@uakari.primate.wisc.edu>, bin@primate.wisc.edu (Brain in
  980. >Neutral) writes:
  981. >> 
  982. >> From article <markw.708223443@wc.novell.com>, by markw@wc.novell.com (Mark
  983. >Wittenberg):
  984. >> > I'd check to make sure that the menu id field of the menu resources
  985. >> > is in fact 102 and 103, respectively (no, not the resource id, but MenuID,
  986. >> > the first field).  ResEdit doesn't automatically set the first field of
  987. >> > a menu to be the same as its resource id, but if it's different the menu
  988. >> > doesn't show up.  Anyone want to take bets that the MenuID fields
  989. >> > are 128 and 129?  This should be in the FAQ if it's not.
  990. >> 
  991. >> Your observations are correct when one is using menu *resources* (I got
  992. >> bit by this myself last weekend, grrr.)  However, the code in question
  993. >> uses NewMenu, not GetMenu, so this can't be the answer: no resources are
  994. >> involved.
  995.  
  996. >Please keep in mind that normally it is just fine for menu IDs to be different
  997. >from resource IDs. The problem comes up when you use something that erroneously
  998. >(or as a matter of convenience) assumes they are the same. This includes MacApp,
  999. >TCL, and the System 7 Popupmenu CDEF. In plain old applications, you can make
  1000. >the resource ID different from the menu ID.
  1001.  
  1002. >--
  1003. >Keith Rollin
  1004. >Phantom Programmer
  1005. >Taligent, Inc.
  1006.  
  1007. 1.  Yes, thanks, Paul, but I guess "Brain in Neutral" describes me, not
  1008. you; I don't seem to have read the source very carefully.
  1009.  
  1010. 2.  Yes, thanks, Keith, but it's been such a long time since I've programmed
  1011. in plain C that I just forgot about it.
  1012.  
  1013. So I guess next time I'll read carefully and then think before posting.
  1014. Now I remember why I normally reply by mail.
  1015.  
  1016. /markw
  1017. - --
  1018. - ---
  1019. Mark Wittenberg            Voice:        (510) 975-4512
  1020. Novell, Inc.            Internet:    markw@wc.novell.com
  1021. 1340 Treat Blvd. Suite 500    UUCP:        uunet!kinetics!markw
  1022. Walnut Creek, CA 94596        AppleLink:    NOVELL.WCENG
  1023.                 FAX:        (510) 947-1238
  1024.  
  1025. +++++++++++++++++++++++++++
  1026.  
  1027. From: hall@bcstec.ca.boeing.com (Robert J. Hall)
  1028. Date: 11 Jun 92 17:30:57 GMT
  1029. Organization: Boeing Computer Services, Seattle
  1030.  
  1031.  
  1032.  > I'm using Think C 5.0.2 and am having trouble getting menus to show up on
  1033.  > bar.  They work fine, but only one is visible.
  1034.  
  1035. I've run into this problem once or twice. It could be a bug in ResEdit. I
  1036. created or copied a new resource file from one of the Think C Demos, copied
  1037. the old Menu's into the new resource file, then fired up the program. All
  1038. the menu's showed up fine. Pretty wierd, huh? If that fails, you can always
  1039. try to DeRez the resource file, then Sarez the result into a new file.
  1040.  
  1041. Of course, it could be that your menu ID's are wrong.
  1042. - -- 
  1043.   Robert J. Hall
  1044.   Systems Analyst, Boeing Computer Services
  1045.   "This load of tripe is mine and mine alone."
  1046.  
  1047. +++++++++++++++++++++++++++
  1048.  
  1049. From: djpegg@utkvx1.utk.edu (PEGG, DAVID J)
  1050. Organization: University of Tennessee Computing Center
  1051. Date: Fri, 12 Jun 1992 18:07:00 GMT
  1052.  
  1053. In article <2821@bcstec.ca.boeing.com>, hall@bcstec.ca.boeing.com (Robert J. Hall) writes...
  1054. > > I'm using Think C 5.0.2 and am having trouble getting menus to show up on
  1055. > > bar.  They work fine, but only one is visible.
  1056. >I've run into this problem once or twice. It could be a bug in ResEdit. I
  1057. >created or copied a new resource file from one of the Think C Demos, copied
  1058. >the old Menu's into the new resource file, then fired up the program. All
  1059. >the menu's showed up fine. Pretty wierd, huh? If that fails, you can always
  1060. >try to DeRez the resource file, then Sarez the result into a new file.
  1061. >Of course, it could be that your menu ID's are wrong.
  1062. >-- 
  1063. >  Robert J. Hall
  1064. >  Systems Analyst, Boeing Computer Services
  1065. >  "This load of tripe is mine and mine alone."
  1066.  
  1067. Thanks, but I found the problem.  I have an extension called NoBalloonMenu
  1068. which removes balloon help from the finder menu.  Apparantly it doesn't
  1069. know when to stop.  Took it out and everything works fine.
  1070.  
  1071. Thanks anyway,
  1072. Joe Dellwo
  1073. Univ. of Tennesse
  1074.  
  1075. +++++++++++++++++++++++++++
  1076.  
  1077. From: andrews@sp1.csrd.uiuc.edu (John Andrews)
  1078. Organization: UIUC Center for Supercomputing Research and Development
  1079. Date: Fri, 12 Jun 92 18:39:44 GMT
  1080.  
  1081. hall@bcstec.ca.boeing.com (Robert J. Hall) writes:
  1082.  
  1083. > > I'm using Think C 5.0.2 and am having trouble getting menus to show up on
  1084. > > bar.  They work fine, but only one is visible.
  1085.  
  1086. >Of course, it could be that your menu ID's are wrong.
  1087.  
  1088. Yea, this is a likely cause.  I made this mistake and got the symptom of
  1089. only one menu showing up.  Original poster, make sure you set both the
  1090. Menu ID and the Menu Resource ID, generally to the same number.  The MDEF ID
  1091. is usually set to 0.
  1092.  
  1093. - --
  1094. John Andrews (andrews@csrd.uiuc.edu) "He who dies with the shortest .sig, wins"
  1095. Graduate Research Assistant, Center for Supercomputing R&D, Urbana, IL
  1096.  
  1097. +++++++++++++++++++++++++++
  1098.  
  1099. From: hall@bcstec.ca.boeing.com (Robert J. Hall)
  1100. Date: 15 Jun 92 17:29:33 GMT
  1101. Organization: Boeing Computer Services, Seattle
  1102.  
  1103.  
  1104.  > > > I'm using Think C 5.0.2 and am having trouble getting menus to show up
  1105.  > > > on the bar.  They work fine, but only one is visible.
  1106.  
  1107.  > > Of course, it could be that your menu ID's are wrong.
  1108.  
  1109.  > Yea, this is a likely cause.  I made this mistake and got the symptom of
  1110.  > only one menu showing up.  Original poster, make sure you set both the
  1111.  > Menu ID and the Menu Resource ID, generally to the same number.  The MDEF ID
  1112.  > is usually set to 0.
  1113.  
  1114. Yep, that fixed the problem. I guess the fact that the Menu ID was hidden under
  1115. an obscure menu pick, instead of the menu dialog in ResEdit, had me fooled into
  1116. thinking the Res ID & Menu ID would be the same. *sigh* Live and learn...]
  1117.  
  1118. Next problem...I am creating multiple documents in Think C. They each use the
  1119. same PopupMenu's. However, each document can have a different pick in the
  1120. corresponding popup menu. Now when I select an item in the first document's
  1121. popup menu, it also shows up checked in the second document's popup menu.
  1122. I've tried various things such as Automatic Checking on or off; trying to
  1123. clear and reset the checked items; etc., without success. Short of accessing
  1124. the protected menuID variable in the PopupMenu instance, and turning off all
  1125. the check marks after a switch between the documents, is there a clean way
  1126. to resolve this problem?          
  1127.  
  1128. The document is being used as a gopher and the Popups are activated by means
  1129. of a PopupPane instance under each document.
  1130.  
  1131. Thanks in advance for your help!
  1132.  
  1133. - -- 
  1134.  
  1135.   Robert J. Hall
  1136.   Systems Analyst, Boeing Computer Services
  1137.  
  1138. +++++++++++++++++++++++++++
  1139.  
  1140. From: 9999cs02@uhdvx3 (Tina Marie!)
  1141. Organization: University of Houston-Downtown
  1142. Date: Tue, 16 Jun 1992 01:46:00 GMT
  1143.  
  1144. (Robert J. Hall) writes...
  1145. > > > > I'm using Think C 5.0.2 and am having trouble getting menus to show up
  1146. > > > > on the bar.  They work fine, but only one is visible.
  1147. > > > Of course, it could be that your menu ID's are wrong.
  1148. > > Yea, this is a likely cause.  I made this mistake and got the symptom of
  1149. > > only one menu showing up.  Original poster, make sure you set both the
  1150. > > Menu ID and the Menu Resource ID, generally to the same number.  The MDEF ID
  1151. > > is usually set to 0.
  1152. >Yep, that fixed the problem. I guess the fact that the Menu ID was hidden under
  1153. >an obscure menu pick, instead of the menu dialog in ResEdit, had me fooled into
  1154. >thinking the Res ID & Menu ID would be the same. *sigh* Live and learn...]
  1155.  
  1156.     Okay...I used to do this constatly, until I found out that if you
  1157.     change the resource ID for a menu in ResEdit when the menu was open,
  1158.     it will ask you if you want to change the Menu ID as well.  Now, I
  1159.     never change a resource ID without the menu open.  Saves a lot of
  1160.     hours of debugging.
  1161.  
  1162. >Next problem...I am creating multiple documents in Think C. They each use the
  1163. >same PopupMenu's. However, each document can have a different pick in the
  1164. >corresponding popup menu. Now when I select an item in the first document's
  1165. >popup menu, it also shows up checked in the second document's popup menu.
  1166. >I've tried various things such as Automatic Checking on or off; trying to
  1167. >clear and reset the checked items; etc., without success. Short of accessing
  1168. >the protected menuID variable in the PopupMenu instance, and turning off all
  1169. >the check marks after a switch between the documents, is there a clean way
  1170. >to resolve this problem?          
  1171. >The document is being used as a gopher and the Popups are activated by means
  1172. >of a PopupPane instance under each document.
  1173. >Thanks in advance for your help!
  1174.  
  1175.     Okay.  I had a similar problem not long ago, and I came up with two
  1176.     solutions.  
  1177.  
  1178.     A) Read in the menus from string list resources, and build them on 
  1179.     the fly, making sure to give each one a unique menu ID.
  1180.  
  1181.     B) (what I did) Subclass CPopupMenu, overridding PopupSelect and
  1182.     GetCheckedItem. Add your own instance variable to keep track of the
  1183.     currently checked item.  At the top of PopupSelect, uncheck the menu
  1184.     item that is checked, and check yours.  After an item is selected, 
  1185.     set yours again.  Also, you'll need to override GetCheckedItem, or
  1186.     the wrong value may be displayed in your PopupPane after a refresh.
  1187.  
  1188.     B) also works well if you want to do anything else neat, like add
  1189.     hierarchical menus that need to be underlined instead of checked.
  1190.  
  1191.     If you still have problems, send me e-mail, and I'll be more
  1192.     detailed.
  1193.  
  1194.     Tina Femea
  1195.  
  1196.     Aspiring to be a Mac Wizard
  1197.     9999cs02@dt3.dt.uh.edu
  1198.  
  1199. +++++++++++++++++++++++++++
  1200.  
  1201. From: hall@bcstec.ca.boeing.com (Robert J. Hall)
  1202. Date: 16 Jun 92 21:49:33 GMT
  1203. Organization: Boeing Computer Services, Seattle
  1204.  
  1205.  
  1206.  > B) (what I did) Subclass CPopupMenu, overridding PopupSelect and
  1207.  > GetCheckedItem. Add your own instance variable to keep track of the
  1208.  > currently checked item.  At the top of PopupSelect, uncheck the menu
  1209.  > item that is checked, and check yours.  After an item is selected,
  1210.  > set yours again.  Also, you'll need to override GetCheckedItem, or
  1211.  > the wrong value may be displayed in your PopupPane after a refresh.
  1212.  
  1213. Yup, that's more or less what I came up with. I didn't think of the refresh
  1214. fix in GetCheckedItem, however. Thanks for the tip! Now on to CEditText...
  1215. - -- 
  1216.  
  1217.   Bob Hall - Systems Analyst, Boeing Computer Services
  1218.  
  1219. ---------------------------
  1220.  
  1221. End of C.S.M.P. Digest
  1222. **********************
  1223.